import time

from Base import Base
from selenium.webdriver.common.by import By

class Page(Base):
    # 定位器
    # 元素操作方法的封装

    # 断言1-登录 /html/body/div[1]/div/section/section/main/div[1]/div[1]/span
    # 1.输入账号
    user_loc=(By.XPATH,'/html/body/div[1]/div/section/section/main/div[1]/div[2]/div[1]/div/input')
    def username(self):
        self.send_keys(self.user_loc,'ltt')

    # 2.输入密码
    pwd_loc=(By.XPATH,'/html/body/div[1]/div/section/section/main/div[1]/div[2]/div[2]/div/input')
    def password(self):
        self.send_keys(self.pwd_loc,'123456')

    # 3.点击登录
    login_loc=(By.XPATH,'/html/body/div[1]/div/section/section/main/div[1]/div[2]/button[2]/span')
    def loginbtn(self):
        self.click(self.login_loc)

    # 4.点击确认
    queren_loc=(By.XPATH,'/html/body/div[1]/div/section/section/main/div[2]/div/div/div/div[2]/button[2]/span')
    def querenbtn(self):
        self.click(self.queren_loc)

    # 登录逻辑
    def login_luoji(self):
        self.open_url('http://localhost:8081/lxyk2login')
        time.sleep(2)
        self.username()
        time.sleep(2)
        self.password()
        time.sleep(2)
        self.loginbtn()
        time.sleep(2)
        self.querenbtn()
        time.sleep(2)
